#include <iostream>
#include <algorithm>
using namespace std;
int *arr;
void Q(int left, int right)
{
    if (left >= right)
        return;
    int key = arr[left], t, l = left, r = right + 1;
    int i;
    for (i = left; i <= right; i++)
    {
        cout << arr[i];
    }
    cout << "\nl:" << l << " r:" << r << "\n\n";
    while (1)
    {
        while (1)
        {
            if (arr[++l] > key)
                break;
            if (l == r)
                break;
        }
        while (1)
        {
            if (arr[--r] < key)
                break;
            if (r == l)
                break;
        }
        if (l > r)
            break;
        t = arr[l];
        arr[l] = arr[r];
        arr[r] = t;
    }
    t = arr[left];
    arr[left] = arr[r];
    arr[r] = t;
    Q(left, r - 1);
    Q(r + 1, right);
}
int main()
{
    int i, j, N;
    cin >> N;
    arr = (int *)malloc(N * 10);
    for (i = 0; i < N; i++)
    {
        cin >> arr[i];
    }
    Q(0, N - 1);
    for (i = 0; i < N; i++)
    {
        cout << arr[i];
    }
    return 0;
}